package data.composition.factory;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.RandomUtil;
import lombok.Data;

import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

/**
 * @author ZhangJinyu
 * @since 2024-12-13
 */
@Data
public class Student {
    private Long id;
    private String name;
    private List<Long> teacherIds;
    private List<Teacher> teachers;
    private List<String> teacherNames;
    private School school;
    private Long schoolId;
    private String schoolName;
    private List<String> teacherGenders;

    public static List<Student> demo1() {
        List<Student> students = new LinkedList<>();
        for (int i = 0; i < 10; i++) {
            Student student = new Student();
            student.setId((long) (i + 1));
            student.setName("学生" + i);
            student.setTeacherIds(new LinkedList<>(new HashSet<>(List.of(RandomUtil.randomLong(1, 10), RandomUtil.randomLong(1, 10), RandomUtil.randomLong(1, 10), RandomUtil.randomLong(1, 10)))));
            student.setSchoolId(1L);
            students.add(student);
        }
        return students;
    }

    public static List<Map<String, Object>> demo2() {
        return demo1().stream().map(BeanUtil::beanToMap).toList();
    }
}
